/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * HoofdPagina.java
 *
 * Created on 17-mrt-2011, 11:29:06
 */
package view;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.KeyEvent;
import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingWorker;
import javax.swing.text.BadLocationException;
import main.ApplicatieMain;
import model.FixedSizeDocument;
import model.User;
import serverComm.CommConnection;

/**
 *
 * @author Jeroen
 */
public class MultiSpelPagina extends javax.swing.JPanel {

    private CommConnection server;
    private ApplicatieMain applicatieMain;
    private int seconds = 0;
    private int gottenScore = 0;
    private Timer timer;
    private int opponentId;
    private String username;
    private User opponent;

    /** Creates new form HoofdPagina */
    public MultiSpelPagina(User opponent, boolean wordChooser) {

        applicatieMain = ApplicatieMain.getInstance();
        initComponents();

        this.opponentId = opponent.getUserID();
        this.server = applicatieMain.getCommServer();
        this.username = applicatieMain.getUsername();
        this.opponent = opponent;
        jlHint.setVisible(false);
        jButton1.setVisible(true);
        spelerNameLabel.setText(username);
        spelerNameLabelSidebar.setText(username);
        tegenstanderNameLabel.setText(opponent.getName());

        //If the client is accepting a game, it retrieves the word from the database
        nieuwSpel(wordChooser);
        
        //        labelPogingen.setText("0" + "/" + applicatieMain.getMaxPoging() + " pogingen");
        jTextArea2.addKeyListener(new java.awt.event.KeyAdapter() {

            @Override
            public void keyTyped(final KeyEvent e) {
                if (e.getKeyChar() == '\n') {
                    try {
                        jTextArea2.setText(jTextArea2.getText(0, jTextArea2.getDocument().getLength() - 1));
                    } catch (BadLocationException ex) {
                        Logger.getLogger(MultiSpelPagina.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    sendMessageButtonActionPerformed(null);
                }
            }
        });

    }



    public void nieuwSpel(boolean wordChooser){
        model.WoordRaden raad = new model.WoordRaden();
        if (wordChooser) {
            raad.nieuwWoord();

            server.getCommOut().setWord(applicatieMain.getGalgjeWoord());
        } else {
            do {
            raad.setWoord(applicatieMain.getGalgjeWoord());
            } while (applicatieMain.getGalgjeWoord() == null);
        }
        String galgjewoord = new String(raad.getVerborgenWoord(true));
        labelGalgjeWoord.setText(galgjewoord);
        labelOpponentGalgjeWoord.setText(galgjewoord);
        jlHint.setVisible(false);
        jButton1.setVisible(true);
        jlHint.setText(applicatieMain.getHintWoord());
        labelPogingen.setText("0" + "/" + applicatieMain.getMaxPoging() + " pogingen");
        applicatieMain.setNieuwSpelPlayer(0);
        applicatieMain.setNieuwSpelOpponent(0);

        //jlHint.setVisible(false);
        //jButton1.setVisible(true);
        //jlHint.setText(applicatieMain.getHintWoord());
        labelLetterA.setBackground(new Color(255,153,0));
        labelLetterB.setBackground(new Color(255,153,0));
        labelLetterC.setBackground(new Color(255,153,0));
        labelLetterD.setBackground(new Color(255,153,0));
        labelLetterE.setBackground(new Color(255,153,0));
        labelLetterF.setBackground(new Color(255,153,0));
        labelLetterG.setBackground(new Color(255,153,0));
        labelLetterH.setBackground(new Color(255,153,0));
        labelLetterI.setBackground(new Color(255,153,0));
        labelLetterJ.setBackground(new Color(255,153,0));
        labelLetterK.setBackground(new Color(255,153,0));
        labelLetterL.setBackground(new Color(255,153,0));
        labelLetterM.setBackground(new Color(255,153,0));
        labelLetterN.setBackground(new Color(255,153,0));
        labelLetterO.setBackground(new Color(255,153,0));
        labelLetterP.setBackground(new Color(255,153,0));
        labelLetterQ.setBackground(new Color(255,153,0));
        labelLetterR.setBackground(new Color(255,153,0));
        labelLetterS.setBackground(new Color(255,153,0));
        labelLetterT.setBackground(new Color(255,153,0));
        labelLetterU.setBackground(new Color(255,153,0));
        labelLetterV.setBackground(new Color(255,153,0));
        labelLetterW.setBackground(new Color(255,153,0));
        labelLetterX.setBackground(new Color(255,153,0));
        labelLetterY.setBackground(new Color(255,153,0));
        labelLetterZ.setBackground(new Color(255,153,0));
        labelHangmanImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Galg0.png")));
        updateOpponentImage(0);
        initTimer();
    }

    private void initTimer() {
        if (timer != null) {
            timer.cancel();
        }

        timer = new Timer();
        timer.scheduleAtFixedRate(new TimerTask() {

            int counter = seconds;

            public void run() {
                if (applicatieMain.isPlaying()) {
                    counter = seconds;
                    counter++;
                    seconds = counter;
                    jLabel5.setText(Integer.toString(counter) + " sec.");
                }
            }
        }, new Date(), 1000);
    }

    public int calcDifficulty() {
        //applicatieMain.requestUserDifficulty(applicatieMain.getUsername());
        applicatieMain.updateUserDifficulty(applicatieMain.getUsername());
        int niveau = applicatieMain.getUserNiveau();
        int level = 0;
        int count = applicatieMain.getGeraden();
        int time = seconds;
        int score = new Integer((((100 - time) - count) + 13));
        if (score < 20) {
            level = -2;
        } else if (score < 40) {
            level = -1;
        } else if (score < 60) {
            level = 1;
        } else if (score < 80) {
            level = 2;
        } else if (score < 100) {
            level = 4;
        } else if (score >= 100) {
            level = 8;
        }
        niveau = niveau + level;
        if (niveau <= 1) {
            niveau = 1;
        }
        if (niveau >= 100) {
            niveau = 10;
        }
        return niveau;
    }

    private void earnScore() {
        int bonus = 50;
        int count = applicatieMain.getGeraden();
        int niveau = applicatieMain.getDifficulty();
        int time = seconds;
        if (time >= 100) {
            time = 100;
        }
        if (count == 0) {
            bonus += 30;
        }
        int score = (((((100 - time) - count) + 13) * niveau) + bonus);
        gottenScore = score;
        System.out.println("Behaalde score: " + score);
        int oldscore = applicatieMain.getScore();
        int userScore = score + oldscore;
        applicatieMain.updateScore(userScore);
        applicatieMain.userScore(applicatieMain.getUsername());
        jLabel2.setText(Integer.toString(userScore));
    }

    private void winUpdate() {
        labelGalgjeWoord.setText("GEWONNEN - HET WOORD WAS   \"" + applicatieMain.getGalgjeWoord() + "\"");
        applicatieMain.setPlaying(false);
        earnScore();
        applicatieMain.playSound("beep_2");
        applicatieMain.setUserNiveau(applicatieMain.getUserNiveau()-(calcDifficulty() - applicatieMain.getUserNiveau()));
        applicatieMain.updateUserDifficulty(applicatieMain.getUsername());
        applicatieMain.setGewonnenMulti(applicatieMain.getGewonnenMulti() + 1);
        applicatieMain.updateGewonnenMulti(applicatieMain.getUsername());
        //applicatieMain.setGewonnen(applicatieMain.getGewonnen() + 1);
        showNieuwSpelPopup();
    }

    private void loseUpdate() {
        labelGalgjeWoord.setText("VERLOREN - HET WOORD WAS   \"" + applicatieMain.getGalgjeWoord() + "\"");
        applicatieMain.setPlaying(false);
        applicatieMain.setUserNiveau(calcDifficulty());
        applicatieMain.playSound("buzzer");
        applicatieMain.updateUserDifficulty(applicatieMain.getUsername());
        applicatieMain.setVerlorenMulti(applicatieMain.getVerlorenMulti() + 1);
        applicatieMain.updateVerlorenMulti(applicatieMain.getUsername());

        //applicatieMain.setVerloren(applicatieMain.getVerloren() + 1);
        labelHangmanImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Galg" + applicatieMain.getMaxPoging() + ".png")));
        showNieuwSpelPopup();
    }

    public void updateChat(String message) {
        jTextArea1.append("\n" + message);
        jTextArea1.setCaretPosition(jTextArea1.getDocument().getLength());
    }

    public void updateOpponentImage(int opponentImage) {
        System.out.println("Current OpponentImage: " + opponentImage);
        labelOpponentHangmanImage.setIcon(
                new javax.swing.ImageIcon(getClass().getResource("/images/Galg" + opponentImage + ".png")));
        if (opponentImage >= applicatieMain.getMaxPoging()) {
            winUpdate();
        }
    }

    public void updateOpponentWord(String woord){
        boolean letterGevonden = false;
        char[] word = woord.toCharArray();
        for (char c : word) {
            if (c == '_') {
                letterGevonden = true;
                break;
            }
        }
        System.out.println("Opponent Word:" + new String(word));
        labelOpponentGalgjeWoord.setText(woord);
        if(!letterGevonden){
            // Gewonnen
            loseUpdate();
        }
    }

    public void showNieuwSpelPopup(){

        final SwingWorker<Integer, Integer> backgroundWork = new SwingWorker<Integer, Integer>() {

            @Override
            protected final Integer doInBackground() throws Exception {
                // Popup voor tegenstander
                Object[] options = { "Ja", "Nee"};
                int keuze = JOptionPane.showOptionDialog(applicatieMain.getContentPane(), "Wil je nog een keer tegen " + opponent + " spelen?", "Nog een keer?",
                    JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE,
                    null, options, options[0]);
                switch(keuze){
                    default:{
                        System.out.println("Unknown option in keuze OptionDialog");
                        break;
                    }
                    case 0:{
                        System.out.println("OPPONENTNIEUWSPEL:" + applicatieMain.getNieuwSpelOpponent());
                        applicatieMain.setNieuwSpelPlayer(2);
                        if(applicatieMain.getNieuwSpelOpponent() == 2){ // Opponent wil spelen
                            server.getCommOut().setStatus(4);
                            nieuwSpel(false);
                        }
                        else if (applicatieMain.getNieuwSpelOpponent() == 1){ // Opponent wil niet spelen
                            // Is dus al uit het spel...

                            int keuzeOK = JOptionPane.showOptionDialog(applicatieMain.getContentPane(), opponent.getName() + " is de kamer verlaten.", "Lobby",
                                JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
                                null, null, "Verder");
                            switch(keuzeOK){
                                default:{
                                    break;
                                }
                                case 0:{
                                    applicatieMain.showPage(new view.SpelerOptiesPagina());
                                }
                            }
                            server.getCommOut().setStatus(1); // Spel Verlaten
                            server.disconnectServer();
                            applicatieMain.showPage(new Lobby());
                        }
                        else { // Opponent heeft nog niet gedrukt
                            server.getCommOut().setStatus(4);
                            updateChat(opponent.getName() + " heeft nog niet gereageerd.");
                        }
                        break;
                    }
                    case 1:{
                        applicatieMain.setNieuwSpelPlayer(1);
                        server.getCommOut().setStatus(3);
                        server.disconnectServer();
                        applicatieMain.showPage(new Lobby());
                        break;
                    }
                }
                return 100;
            }

            @Override
            protected final void done() {
                System.out.println("SwingWorker-doInBackGround: Popup done");
            }


            protected final void process(List<Integer> chunks) {
                System.out.println("SwingWorker-doInBackGround: Popup process");
            }
        };
        backgroundWork.execute();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        spelerNameLabel = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        labelHangmanImage = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        labelLetterZ = new javax.swing.JLabel();
        labelLetterA = new javax.swing.JLabel();
        labelLetterB = new javax.swing.JLabel();
        labelLetterC = new javax.swing.JLabel();
        labelLetterD = new javax.swing.JLabel();
        labelLetterE = new javax.swing.JLabel();
        labelLetterF = new javax.swing.JLabel();
        labelLetterG = new javax.swing.JLabel();
        labelLetterH = new javax.swing.JLabel();
        labelLetterI = new javax.swing.JLabel();
        labelLetterJ = new javax.swing.JLabel();
        labelLetterK = new javax.swing.JLabel();
        labelLetterM = new javax.swing.JLabel();
        labelLetterL = new javax.swing.JLabel();
        labelLetterN = new javax.swing.JLabel();
        labelLetterO = new javax.swing.JLabel();
        labelLetterP = new javax.swing.JLabel();
        labelLetterQ = new javax.swing.JLabel();
        labelLetterR = new javax.swing.JLabel();
        labelLetterS = new javax.swing.JLabel();
        labelLetterT = new javax.swing.JLabel();
        labelLetterU = new javax.swing.JLabel();
        labelLetterV = new javax.swing.JLabel();
        labelLetterW = new javax.swing.JLabel();
        labelLetterX = new javax.swing.JLabel();
        labelLetterY = new javax.swing.JLabel();
        labelGalgjeWoord = new javax.swing.JLabel();
        jPanel14 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        labelOpponentHangmanImage = new javax.swing.JLabel();
        labelOpponentGalgjeWoord = new javax.swing.JLabel();
        tegenstanderNameLabel = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        sendMessageButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea2 = new javax.swing.JTextArea();
        lblLetterCount = new javax.swing.JLabel();
        buttonStopSpel = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        spelerNameLabelSidebar = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        buttonRaden = new javax.swing.JButton();
        textfieldRaden = new javax.swing.JTextField();
        labelPogingen = new javax.swing.JLabel();
        labelFout = new javax.swing.JLabel();
        labelGoed = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jlHint = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setPreferredSize(new java.awt.Dimension(858, 379));

        jPanel7.setBackground(new java.awt.Color(255, 255, 255));
        jPanel7.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(183, 234, 0), 10, true));

        spelerNameLabel.setFont(new java.awt.Font("Tahoma", 1, 12));
        spelerNameLabel.setText("<PlayerName>");

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));

        labelHangmanImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Galg0.png"))); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(114, 114, 114)
                .addComponent(labelHangmanImage)
                .addContainerGap(138, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(71, Short.MAX_VALUE)
                .addComponent(labelHangmanImage)
                .addContainerGap())
        );

        jPanel5.setBackground(new java.awt.Color(255, 153, 0));
        jPanel5.setLayout(null);

        labelLetterZ.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterZ.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterZ.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterZ.setText("Z");
        labelLetterZ.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterZ.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterZ.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterZ.setOpaque(true);
        labelLetterZ.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterZ.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterZ);
        labelLetterZ.setBounds(430, 40, 30, 30);

        labelLetterA.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterA.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterA.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterA.setText("A");
        labelLetterA.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterA.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterA.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterA.setOpaque(true);
        labelLetterA.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterA.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterA);
        labelLetterA.setBounds(70, 10, 30, 30);

        labelLetterB.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterB.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterB.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterB.setText("B");
        labelLetterB.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterB.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterB.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterB.setOpaque(true);
        labelLetterB.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterB.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterB);
        labelLetterB.setBounds(100, 10, 30, 30);

        labelLetterC.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterC.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterC.setText("C");
        labelLetterC.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterC.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterC.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterC.setOpaque(true);
        labelLetterC.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterC.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterC);
        labelLetterC.setBounds(130, 10, 30, 30);

        labelLetterD.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterD.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterD.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterD.setText("D");
        labelLetterD.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterD.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterD.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterD.setOpaque(true);
        labelLetterD.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterD.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterD);
        labelLetterD.setBounds(160, 10, 30, 30);

        labelLetterE.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterE.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterE.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterE.setText("E");
        labelLetterE.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterE.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterE.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterE.setOpaque(true);
        labelLetterE.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterE.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterE);
        labelLetterE.setBounds(190, 10, 30, 30);

        labelLetterF.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterF.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterF.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterF.setText("F");
        labelLetterF.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterF.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterF.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterF.setOpaque(true);
        labelLetterF.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterF.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterF);
        labelLetterF.setBounds(220, 10, 30, 30);

        labelLetterG.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterG.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterG.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterG.setText("G");
        labelLetterG.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterG.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterG.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterG.setOpaque(true);
        labelLetterG.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterG.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterG);
        labelLetterG.setBounds(250, 10, 30, 30);

        labelLetterH.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterH.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterH.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterH.setText("H");
        labelLetterH.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterH.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterH.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterH.setOpaque(true);
        labelLetterH.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterH.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterH);
        labelLetterH.setBounds(280, 10, 30, 30);

        labelLetterI.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterI.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterI.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterI.setText("I");
        labelLetterI.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterI.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterI.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterI.setOpaque(true);
        labelLetterI.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterI.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterI);
        labelLetterI.setBounds(310, 10, 30, 30);

        labelLetterJ.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterJ.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterJ.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterJ.setText("J");
        labelLetterJ.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterJ.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterJ.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterJ.setOpaque(true);
        labelLetterJ.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterJ.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterJ);
        labelLetterJ.setBounds(340, 10, 30, 30);

        labelLetterK.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterK.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterK.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterK.setText("K");
        labelLetterK.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterK.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterK.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterK.setOpaque(true);
        labelLetterK.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterK.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterK);
        labelLetterK.setBounds(370, 10, 30, 30);

        labelLetterM.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterM.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterM.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterM.setText("M");
        labelLetterM.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterM.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterM.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterM.setOpaque(true);
        labelLetterM.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterM.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterM);
        labelLetterM.setBounds(430, 10, 30, 30);

        labelLetterL.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterL.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterL.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterL.setText("L");
        labelLetterL.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterL.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterL.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterL.setOpaque(true);
        labelLetterL.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterL.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterL);
        labelLetterL.setBounds(400, 10, 30, 30);

        labelLetterN.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterN.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterN.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterN.setText("N");
        labelLetterN.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterN.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterN.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterN.setOpaque(true);
        labelLetterN.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterN.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterN);
        labelLetterN.setBounds(70, 40, 30, 30);

        labelLetterO.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterO.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterO.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterO.setText("O");
        labelLetterO.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterO.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterO.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterO.setOpaque(true);
        labelLetterO.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterO.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterO);
        labelLetterO.setBounds(100, 40, 30, 30);

        labelLetterP.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterP.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterP.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterP.setText("P");
        labelLetterP.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterP.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterP.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterP.setOpaque(true);
        labelLetterP.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterP);
        labelLetterP.setBounds(130, 40, 30, 30);

        labelLetterQ.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterQ.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterQ.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterQ.setText("Q");
        labelLetterQ.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterQ.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterQ.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterQ.setOpaque(true);
        labelLetterQ.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterQ.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterQ);
        labelLetterQ.setBounds(160, 40, 30, 30);

        labelLetterR.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterR.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterR.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterR.setText("R");
        labelLetterR.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterR.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterR.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterR.setOpaque(true);
        labelLetterR.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterR.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterR);
        labelLetterR.setBounds(190, 40, 30, 30);

        labelLetterS.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterS.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterS.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterS.setText("S");
        labelLetterS.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterS.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterS.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterS.setOpaque(true);
        labelLetterS.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterS.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterS);
        labelLetterS.setBounds(220, 40, 30, 30);

        labelLetterT.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterT.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterT.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterT.setText("T");
        labelLetterT.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterT.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterT.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterT.setOpaque(true);
        labelLetterT.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterT);
        labelLetterT.setBounds(250, 40, 30, 30);

        labelLetterU.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterU.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterU.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterU.setText("U");
        labelLetterU.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterU.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterU.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterU.setOpaque(true);
        labelLetterU.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterU.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterU);
        labelLetterU.setBounds(280, 40, 30, 30);

        labelLetterV.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterV.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterV.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterV.setText("V");
        labelLetterV.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterV.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterV.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterV.setOpaque(true);
        labelLetterV.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterV.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterV);
        labelLetterV.setBounds(310, 40, 30, 30);

        labelLetterW.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterW.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterW.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterW.setText("W");
        labelLetterW.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterW.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterW.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterW.setOpaque(true);
        labelLetterW.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterW.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterW);
        labelLetterW.setBounds(340, 40, 30, 30);

        labelLetterX.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterX.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterX.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterX.setText("X");
        labelLetterX.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterX.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterX.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterX.setOpaque(true);
        labelLetterX.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterX.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterX);
        labelLetterX.setBounds(370, 40, 30, 30);

        labelLetterY.setBackground(new java.awt.Color(255, 153, 0));
        labelLetterY.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelLetterY.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelLetterY.setText("Y");
        labelLetterY.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        labelLetterY.setMaximumSize(new java.awt.Dimension(20, 20));
        labelLetterY.setMinimumSize(new java.awt.Dimension(20, 20));
        labelLetterY.setOpaque(true);
        labelLetterY.setPreferredSize(new java.awt.Dimension(20, 20));
        labelLetterY.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                letterClickedLabel(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouseEnteredKeyLabel(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouseExitKeyLabel(evt);
            }
        });
        jPanel5.add(labelLetterY);
        labelLetterY.setBounds(400, 40, 30, 30);

        labelGalgjeWoord.setFont(new java.awt.Font("Tahoma", 1, 18));
        labelGalgjeWoord.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelGalgjeWoord.setText("<GalgjeWoord>");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelGalgjeWoord, javax.swing.GroupLayout.DEFAULT_SIZE, 510, Short.MAX_VALUE)
                    .addComponent(spelerNameLabel)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 530, Short.MAX_VALUE)
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(spelerNameLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(labelGalgjeWoord, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPanel14.setBackground(new java.awt.Color(255, 255, 255));
        jPanel14.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(183, 234, 0), 10, true));

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204)));

        labelOpponentHangmanImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Galg0.png"))); // NOI18N

        labelOpponentGalgjeWoord.setFont(new java.awt.Font("Tahoma", 1, 14));
        labelOpponentGalgjeWoord.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelOpponentGalgjeWoord.setText("<OpponentGalgjeWoord>");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelOpponentGalgjeWoord, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE)
                    .addComponent(labelOpponentHangmanImage, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelOpponentHangmanImage, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(labelOpponentGalgjeWoord, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        tegenstanderNameLabel.setFont(new java.awt.Font("Tahoma", 1, 12));
        tegenstanderNameLabel.setText("<OpponentName>");

        jTextArea1.setColumns(20);
        jTextArea1.setEditable(false);
        jTextArea1.setFont(new java.awt.Font("Tahoma", 0, 13));
        jTextArea1.setLineWrap(true);
        jTextArea1.setRows(5);
        jTextArea1.setText("Welkom bij hangman.");
        jScrollPane2.setViewportView(jTextArea1);

        sendMessageButton.setBackground(new java.awt.Color(153, 255, 51));
        sendMessageButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        sendMessageButton.setText("Send");
        sendMessageButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        sendMessageButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                sendMessageButtonEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                sendMessageButtonExit(evt);
            }
        });
        sendMessageButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sendMessageButtonActionPerformed(evt);
            }
        });

        jTextArea2.setColumns(20);
        jTextArea2.setDocument(new FixedSizeDocument(140));
        jTextArea2.setLineWrap(true);
        jTextArea2.setRows(3);
        jTextArea2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextArea2KeyTyped(evt);
            }
        });
        jScrollPane1.setViewportView(jTextArea2);

        lblLetterCount.setText("140");

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(tegenstanderNameLabel, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addComponent(lblLetterCount)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 213, Short.MAX_VALUE)
                        .addComponent(sendMessageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tegenstanderNameLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sendMessageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblLetterCount))
                .addGap(11, 11, 11))
        );

        buttonStopSpel.setFont(new java.awt.Font("Tahoma", 1, 12));
        buttonStopSpel.setForeground(new java.awt.Color(255, 0, 0));
        buttonStopSpel.setText("Stop Spel");
        buttonStopSpel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 0, 0)));
        buttonStopSpel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        buttonStopSpel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonStopSpelActionPerformed(evt);
            }
        });

        jButton2.setText("Profiel");
        jButton2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/beker.gif"))); // NOI18N
        jLabel2.setText("Geen score");

        spelerNameLabelSidebar.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        spelerNameLabelSidebar.setText("<UserName>");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel5.setText("00:00");

        buttonRaden.setText("Raad Woord");
        buttonRaden.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        buttonRaden.setEnabled(false);
        buttonRaden.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonRadenActionPerformed(evt);
            }
        });

        textfieldRaden.setFont(new java.awt.Font("Tahoma", 0, 10));
        textfieldRaden.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        textfieldRaden.setText("Type het woord");
        textfieldRaden.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 255, 0)));
        textfieldRaden.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        textfieldRaden.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                textfieldRadentextFieldRadenFocusGained(evt);
            }
        });
        textfieldRaden.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                textfieldRadenKeyTyped(evt);
            }
        });

        labelPogingen.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelPogingen.setText("0/12 pogingen");

        labelFout.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelFout.setForeground(new java.awt.Color(255, 0, 0));
        labelFout.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelFout.setText("Verloren: 0");

        labelGoed.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelGoed.setForeground(new java.awt.Color(0, 255, 0));
        labelGoed.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelGoed.setText("Gewonnen: 0");

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(labelGoed, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
            .addComponent(labelFout, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
            .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
            .addComponent(buttonRaden, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
            .addComponent(textfieldRaden, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
            .addComponent(labelPogingen, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(35, 35, 35)
                .addComponent(buttonRaden)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textfieldRaden, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(labelPogingen)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 141, Short.MAX_VALUE)
                .addComponent(labelGoed)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(labelFout)
                .addContainerGap())
        );

        jButton1.setText("Hint");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jlHint.setFont(new java.awt.Font("Tahoma", 1, 14));
        jlHint.setText("HINT");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(buttonStopSpel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(spelerNameLabelSidebar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(309, 309, 309)
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jlHint)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(spelerNameLabelSidebar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonStopSpel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jlHint))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 1054, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1219, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 72, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 73, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 526, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void sendMessageButtonEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sendMessageButtonEntered
        sendMessageButton.setBackground(new java.awt.Color(204, 235, 204));
}//GEN-LAST:event_sendMessageButtonEntered

    private void sendMessageButtonExit(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sendMessageButtonExit
        sendMessageButton.setBackground(new java.awt.Color(153, 255, 51));
}//GEN-LAST:event_sendMessageButtonExit

    private void mouseEnteredKeyLabel(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mouseEnteredKeyLabel
        model.WoordRaden raad = new model.WoordRaden();
        JLabel label = (JLabel) evt.getSource(); // Ffies de component casten
        if (raad.isLetterGebruikt(label.getText().charAt(0))) {
            evt.getComponent().setBackground(new Color(20, 20, 20));
        } else {
            evt.getComponent().setBackground(Color.white);
        }

        Font labelFont = evt.getComponent().getFont();
        evt.getComponent().setFont(new Font(labelFont.getName(), labelFont.getStyle(), 20));
    }//GEN-LAST:event_mouseEnteredKeyLabel

    private void mouseExitKeyLabel(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mouseExitKeyLabel
        model.WoordRaden raad = new model.WoordRaden();
        JLabel label = (JLabel) evt.getSource(); // Ffies de component casten
        if (raad.isLetterGebruikt(label.getText().charAt(0))) {
            evt.getComponent().setBackground(new Color(20, 20, 20));
        } else {
            evt.getComponent().setBackground(new Color(255, 153, 0));
        }

        Font labelFont = evt.getComponent().getFont();
        evt.getComponent().setFont(new Font(labelFont.getName(), labelFont.getStyle(), 12));
    }//GEN-LAST:event_mouseExitKeyLabel

    private void letterClickedLabel(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_letterClickedLabel
        if (applicatieMain.isPlaying()) {
            JLabel label = (JLabel) evt.getSource(); // Ffies de component casten
            model.WoordRaden raad = new model.WoordRaden();
            if (!raad.isLetterGebruikt(label.getText().charAt(0))) {
                raad.voegGebruikteLetterToe(label.getText().charAt(0));
                label.setBackground(new Color(20, 20, 20));
                String verborgenwoord = new String(raad.getVerborgenWoord(true));
                labelGalgjeWoord.setText(verborgenwoord);
  
                int count = applicatieMain.getGeraden();
                for (char c : applicatieMain.getGebruikteLetters()) {
                    if (raad.isGeldigeLetter(c)) {
                        String str = applicatieMain.getGalgjeWoord().toUpperCase();
                        for (int i = 0; i < str.length(); i++) {
                            if (str.charAt(i) == c) {
                                break;
                            } else if (i == str.length() - 1) {
                                count++;
                            }
                        }
                    }
                }
     
                labelPogingen.setText(count + "/" + applicatieMain.getMaxPoging() + " pogingen");

                String word = new String(raad.getVerborgenWoord(false));
                server.getCommOut().setMyCurrentImageAndGuessedLetters(count, word);      //send the imagecount to the server
                labelHangmanImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Galg" + count + ".png"))); // Image
                if (raad.isWoordGeraden()) {
                    winUpdate(); // Gewonnen
                }

                if (count >= applicatieMain.getMaxPoging()) {
                    loseUpdate();
                }
            }
        } else {
            System.out.println("ERROR: Je moet eerst een nieuw spel starten.");
        }
    }//GEN-LAST:event_letterClickedLabel

    private void sendMessageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendMessageButtonActionPerformed

        if (jTextArea2.getText().isEmpty()) {
            JOptionPane.showMessageDialog(this, "Je mag geen lege berichten sturen!",
                    "Fout opgetreden",
                    JOptionPane.ERROR_MESSAGE);
        } else {
            String message = (username + ": " + jTextArea2.getText());
            jTextArea2.setText("");

            updateChat(message);
            server.getCommOut().sendChatMessage(message);
        }
    }//GEN-LAST:event_sendMessageButtonActionPerformed

    private void buttonStopSpelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStopSpelActionPerformed
        Object[] options = {"Ja", "Nee"};
        int keuze = JOptionPane.showOptionDialog(this, "Weet je zeker dat je wil stoppen?", "Let op!",
                JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
                null, options, options[0]);
        switch (keuze) {
            default: {
                System.out.println("Unknown option in keuze OptionDialog");
            }
            case 0: {
                server.getCommOut().setStatus(1); // Spel Verlaten
                server.disconnectServer();
                applicatieMain.showPage(new SpelerOptiesPagina());

                break;
            }
            case 1: {
                System.out.println("Speler drukt");
                break;
            }
        }
    }//GEN-LAST:event_buttonStopSpelActionPerformed

    private void buttonRadenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRadenActionPerformed
        if(applicatieMain.isPlaying()){
            model.WoordRaden raad = new model.WoordRaden();
            if(!textfieldRaden.getText().equals("Type het woord") && !textfieldRaden.getText().isEmpty()){
                if(raad.isGeldigAntwoord(textfieldRaden.getText())){
                    winUpdate();
                } else {
                    applicatieMain.setGeraden(applicatieMain.getGeraden()+1);
                    int count = applicatieMain.getGeraden();
                    for (char c : applicatieMain.getGebruikteLetters()) {
                        if(raad.isGeldigeLetter(c)){
                            String str = applicatieMain.getGalgjeWoord().toUpperCase();
                            for (int i = 0; i < str.length(); i++) {
                                if(str.charAt(i) == c){
                                    //applicatieMain.playSound("Correct.wav");
                                    break;
                                } else if(i == str.length()-1){
                                    //applicatieMain.playSound("Mistake.wav");
                                    count++;
                                }
                            }
                        }
                    }
                    if(count >= applicatieMain.getMaxPoging()){
                        loseUpdate();
                    }
                    labelPogingen.setText(count + "/" + applicatieMain.getMaxPoging() + " pogingen");
                    labelHangmanImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Galg" + count + ".png"))); // Image
                }
                textfieldRaden.setText("Type het woord");
            } else{
                System.out.println("ERROR: Je moet eerst een woord invullen.");
            }
        } else{
            System.out.println("ERROR: Je moet eerst een nieuw spel starten.");
        }
        buttonRaden.setEnabled(false);
}//GEN-LAST:event_buttonRadenActionPerformed

    private void textfieldRadentextFieldRadenFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_textfieldRadentextFieldRadenFocusGained
        JTextField label = (JTextField)evt.getSource();
        label.setText("");
}//GEN-LAST:event_textfieldRadentextFieldRadenFocusGained

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        Object[] options = {"Ja", "Nee"};
        int keuze = JOptionPane.showOptionDialog(this, "Je gaat nu naar je profielpagina. Dit zal de ronde stoppen! Weet je het zeker?", "Let op!",
                JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
                null, options, options[0]);
        switch (keuze) {
            default: {
                System.out.println("Unknown option in keuze OptionDialog");
            }
            case 0: {
                server.getCommOut().setStatus(1); // Spel Verlaten
                server.disconnectServer();
                applicatieMain.showPage(new ProfilePage());
                break;
            }
            case 1: {
                System.out.println("Speler drukt");
                break;
            }
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jTextArea2KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextArea2KeyTyped
        lblLetterCount.setText(String.valueOf(140-jTextArea2.getDocument().getLength()));
    }//GEN-LAST:event_jTextArea2KeyTyped

    private void textfieldRadenKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textfieldRadenKeyTyped
        if(!textfieldRaden.getText().equals("")){
            buttonRaden.setEnabled(true);
        } else {
            buttonRaden.setEnabled(false);
        }
    }//GEN-LAST:event_textfieldRadenKeyTyped

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        jlHint.setVisible(true);
        jButton1.setVisible(false);
    }//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonRaden;
    private javax.swing.JButton buttonStopSpel;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextArea2;
    private javax.swing.JLabel jlHint;
    private javax.swing.JLabel labelFout;
    private javax.swing.JLabel labelGalgjeWoord;
    private javax.swing.JLabel labelGoed;
    private javax.swing.JLabel labelHangmanImage;
    private javax.swing.JLabel labelLetterA;
    private javax.swing.JLabel labelLetterB;
    private javax.swing.JLabel labelLetterC;
    private javax.swing.JLabel labelLetterD;
    private javax.swing.JLabel labelLetterE;
    private javax.swing.JLabel labelLetterF;
    private javax.swing.JLabel labelLetterG;
    private javax.swing.JLabel labelLetterH;
    private javax.swing.JLabel labelLetterI;
    private javax.swing.JLabel labelLetterJ;
    private javax.swing.JLabel labelLetterK;
    private javax.swing.JLabel labelLetterL;
    private javax.swing.JLabel labelLetterM;
    private javax.swing.JLabel labelLetterN;
    private javax.swing.JLabel labelLetterO;
    private javax.swing.JLabel labelLetterP;
    private javax.swing.JLabel labelLetterQ;
    private javax.swing.JLabel labelLetterR;
    private javax.swing.JLabel labelLetterS;
    private javax.swing.JLabel labelLetterT;
    private javax.swing.JLabel labelLetterU;
    private javax.swing.JLabel labelLetterV;
    private javax.swing.JLabel labelLetterW;
    private javax.swing.JLabel labelLetterX;
    private javax.swing.JLabel labelLetterY;
    private javax.swing.JLabel labelLetterZ;
    private javax.swing.JLabel labelOpponentGalgjeWoord;
    private javax.swing.JLabel labelOpponentHangmanImage;
    private javax.swing.JLabel labelPogingen;
    private javax.swing.JLabel lblLetterCount;
    private javax.swing.JButton sendMessageButton;
    private javax.swing.JLabel spelerNameLabel;
    private javax.swing.JLabel spelerNameLabelSidebar;
    private javax.swing.JLabel tegenstanderNameLabel;
    private javax.swing.JTextField textfieldRaden;
    // End of variables declaration//GEN-END:variables
}
